import { createRouter, createWebHistory } from "vue-router";

// 每个路由都需要映射到一个组件。
const routes = [
  {
    path: "/",
    name: "login",
    component: () => import("../login/login.vue"),
  },
  {
    path: "/home",
    name: "",
    component: () => import("../components/home/home.vue"),
    redirect: "/media",
    // redirect: to => {
    //     console.log(to);
    //     return {
    //         path: '/media',
    //         query: {  name: '欢迎' }
    //     }
    // },
    children: [
      {
        path: "/media",
        name: "media",
        component: () => import("../components/media/media.vue"),
      },
      {
        path: "/props",
        name: "通信方式",
        component: () => import("../components/props&event/parent.vue"),
      },
      {
        path: "/threeD",
        component: () => import("../components/threeD/threeD.vue"),
      } ,{
        path: "/screenshot",
        component: () => import("../components/screenshot/screenshot.vue"),
      }
      ,{
        path: "/css",
        component: () => import("../components/css/css.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

//导出router
export default router;
